#!/usr/bin/env python
#!coding:utf-8
# @上报脚本例子
import requests
import json

django_user = "admin"
django_pass = "admin"
headers = {"Content-Type": "application/json"}
res = requests.post('http://127.0.0.1:9090/api-token-auth/',
                    '{"username":"%s","password":"%s"}' % (django_user, django_pass), headers=headers)
data = json.loads(res.text)
token = data["token"]
headers["Authorization"] = "JWT %s" % (token)
l = [
    {
        'id': '1',
        'host': '127.0.0.1'
    }
]
Params = json.dumps({
    "reportData": json.dumps(l)

}, indent=4)
r = requests.put('http://127.0.0.1:9090/api/HtmlConfig/7/',
                 Params, headers=headers, verify=False)
print(r.text)
